home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 May / PCpro_2006_05.ISO / files / mobile / fma-2.0-stable-setup.exe / {app} / sframework / plugins / foobar2000.vbs < prev    next >
Encoding:
Text File  |  2004-12-05  |  8.3 KB  |  253 lines

  1. 'FMA Script Framework Plugin
  2. 'foobar2000
  3. 'Lets you control foobar2000
  4. 'Version 1.0
  5. '
  6. 'IF you want to see the current title playing and being able to adjust the volume, download the
  7. 'fb2k plugin foo_winamp_spam ( http://www.r1ch.net/stuff/foobar/foo_winamp_spam-0.74.zip )
  8. 'and install it into your /foobar2000/components/ directory.
  9.  
  10. 'TODO:
  11. '- Testing
  12.  
  13. Class foobar2000
  14.     
  15.     Private m_Self
  16.     Private mainMenu
  17.     
  18.     'Some info about the plugin
  19.     Public Property Get SHOWABLE 'Do I have a menu?
  20.         SHOWABLE    = True
  21.     End Property
  22.     Public Property Get TITLE 'What's my name?
  23.         TITLE       = "foobar2000"
  24.     End Property
  25.     Public Property Get DESCRIPTION 'What's my purpose?
  26.         DESCRIPTION = "Lets you control foobar2000"
  27.     End Property
  28.     Public Property Get AUTHOR 'Who created me?
  29.         AUTHOR      = "cynos, partially based on winamp script"
  30.     End Property
  31.     Public Property Get URL 'Were can I be found? Where can you get more information?
  32.         URL = "http://fma.xinium.com/"
  33.     End Property
  34.     
  35.     'Who am I?
  36.     Public Property Let Self (s)
  37.         m_Self = s
  38.         ' Some init stuff here:
  39.         If IsEmpty(Settings(Me, "Title")) or Settings(Me, "Title") = "" Then Settings(Me, "Title") = "foobar2000"                                   'This isn't needed.
  40.         If IsEmpty(Settings(Me, "Exe"))   or Settings(Me, "Exe")   = "" Then Settings(Me, "Exe")   = "C:\Program Files\foobar2000\foobar2000.exe"
  41.         Set mainMenu = New ManagedMenu
  42.         mainMenu.Title = TITLE
  43.     End Property
  44.     Public Property Get Self
  45.         Self = m_Self
  46.     End Property
  47.     
  48.     'Display me. Eventually put a menu on the screen
  49.     Sub Show()
  50.         '--> Init Menu
  51.         Dim llist
  52.         Set llist = New LinkedList
  53.         Dim bi
  54.         ActiveXManager("WinampCOMLib.WinampCOMObj").PathExe = Fso.GetParentFolderName(Settings(Me, "Exe"))          ' Set up fake API.
  55.         bi = llist.BackInserter
  56.             bi.Item = Array("1 " & ActiveXManager("WinampCOMLib.WinampCOMObj").GetTitlePlaying, Self & ".fbvoid")   ' Get the title playing from the API, doesn't refresh when song ends.
  57.             state = ActiveXManager("WinampCOMLib.WinampCOMObj").GetSongState                                        ' Get the state of the song playing.
  58.             
  59.             If state = "Playing" Then
  60.                 bi.Item = Array("2 Restart",            Self & ".Play")     'Restart (Play) track. If order is random, random track.
  61.             Elseif state = "Paused" Then
  62.                 bi.Item = Array("2 Resume",             Self & ".Play")
  63.             Else
  64.                 bi.Item = Array("2 Play / Start fb2k",  Self & ".Play")
  65.             End If
  66.             
  67.             If state = "Paused" Then
  68.                 bi.Item = Array("3 Resume",             Self & ".Pause")
  69.             Else
  70.                 bi.Item = Array("3 Pause",              Self & ".Pause")
  71.             End If
  72.             
  73.             bi.Item = Array("4 Stop",                   Self & ".Stopp")
  74.             bi.Item = Array("5 Next Track",             Self & ".NextTrack")
  75.             bi.Item = Array("6 Previous Track",         Self & ".PreviousTrack")
  76.             bi.Item = Array("7 Random Track",           Self & ".RandomTrack")
  77.             bi.Item = Array("8 Volume",                 Self & ".Volume")
  78.             bi.Item = Array("9 Order",                  Self & ".Order")
  79.             bi.Item = Array("0 Close",                  Self & ".Close")
  80.         mainMenu.SetList llist
  81.         mainMenu.ShowMenu
  82.     End Sub
  83.     
  84.     Sub fbvoid
  85.         Show    'Just refresh if user clicks the first menu item
  86.     End Sub
  87.     
  88.     Sub Close
  89.         Shell.Exec Settings(Me, "Exe") & " /command:""Foobar2000/Close"""   'Start / Invoke foobar2000.exe with commandline command. It won't load to times.
  90.         Util.Sleep 3000                                                     'Give foobar2000 3secs to close itself
  91.         am.Update
  92.         Show                                                                'Refresh the menu and title playing
  93.     End Sub
  94.     
  95.     Sub Play
  96.         Shell.Exec Settings(Me, "Exe") & " /command:""Playback/Play"""
  97.         am.Update
  98.         Show
  99.     End Sub
  100.         
  101.     Sub Pause
  102.         Shell.Exec Settings(Me, "Exe") & " /command:""Playback/Pause"""
  103.         am.Update
  104.         Show
  105.     End Sub
  106.     
  107.     Sub Stopp
  108.         Shell.Exec Settings(Me, "Exe") & " /command:""Playback/Stop"""
  109.         am.Update
  110.         Show
  111.     End Sub
  112.     
  113.     Sub NextTrack
  114.         Shell.Exec Settings(Me, "Exe") & " /command:""Playback/Next"""
  115.         am.Update
  116.         Show
  117.     End Sub
  118.     
  119.     Sub PreviousTrack
  120.         Shell.Exec Settings(Me, "Exe") & " /command:""Playback/Previous"""
  121.         am.Update
  122.         Show
  123.     End Sub
  124.     
  125.     Sub RandomTrack
  126.         Shell.Exec Settings(Me, "Exe") & " /command:""Playback/Random"""
  127.         am.Update
  128.         Show
  129.     End Sub
  130.     
  131.     ' Order Start
  132.     Sub Order()
  133.         EmptyMenu.ShowMenu
  134.         am.Back = Self & ".OrderQuit" 'Mangage the menu quit by ourselves
  135.         'Joyup -> Default
  136.         KeyManager.RegisterKey KEY_JOYUP,    Self & ".DefaultPress",   STATE_PRESS,   Me
  137.         KeyManager.RegisterKey KEY_JOYUP,    Self & ".DefaultRelease", STATE_RELEASE, Me
  138.         'Joyright -> Repeat One
  139.         KeyManager.RegisterKey KEY_JOYRIGHT, Self & ".RepeatOnePress",   STATE_PRESS,   Me
  140.         KeyManager.RegisterKey KEY_JOYRIGHT, Self & ".RepeatOneRelease", STATE_RELEASE, Me
  141.         'Joydown -> Random
  142.         KeyManager.RegisterKey KEY_JOYDOWN,  Self & ".RandomPress",   STATE_PRESS,   Me
  143.         KeyManager.RegisterKey KEY_JOYDOWN,  Self & ".RandomRelease", STATE_RELEASE, Me
  144.         'Joyleft -> Repeat
  145.         KeyManager.RegisterKey KEY_JOYLEFT,  Self & ".RepeatPress",   STATE_PRESS,   Me
  146.         KeyManager.RegisterKey KEY_JOYLEFT,  Self & ".RepeatRelease", STATE_RELEASE, Me
  147.         
  148.         am.DlgMsgBox "Joy-Up: Default; Joy-Down: Random; Joy-Left: Repeat; Joy-Right: Repeat One", 0
  149.     End Sub
  150.     
  151.     Sub SetOrderDefault
  152.         Shell.Exec Settings(Me, "Exe") & " /command:""Playback/Order/Default"""
  153.     End Sub
  154.     
  155.     Sub SetOrderRepeatOne
  156.         Shell.Exec Settings(Me, "Exe") & " /command:""Playback/Order/Repeat One"""
  157.     End Sub
  158.     
  159.     Sub SetOrderRandom
  160.         Shell.Exec Settings(Me, "Exe") & " /command:""Playback/Order/Random"""
  161.     End Sub
  162.     
  163.     Sub SetOrderRepeat
  164.         Shell.Exec Settings(Me, "Exe") & " /command:""Playback/Order/Repeat"""
  165.     End Sub
  166.         
  167.     Sub DefaultPress
  168.         fma.AddTimer 60, Self & ".SetOrderDefault"
  169.     End Sub
  170.     Sub DefaultRelease
  171.         fma.DeleteTimer Self & ".SetOrderDefault"
  172.         OrderQuit       ' After choosing order: Quit the Dlg
  173.     End Sub
  174.     
  175.     Sub RepeatOnePress
  176.         fma.AddTimer 60, Self & ".SetOrderRepeatOne"
  177.     End Sub
  178.     Sub RepeatOneRelease
  179.         fma.DeleteTimer Self & ".SetOrderRepeatOne"
  180.         OrderQuit
  181.     End Sub
  182.     
  183.     Sub RandomPress
  184.         fma.AddTimer 60, Self & ".SetOrderRandom"
  185.     End Sub
  186.     Sub RandomRelease
  187.         fma.DeleteTimer Self & ".SetOrderRandom"
  188.         OrderQuit
  189.     End Sub
  190.     
  191.     Sub RepeatPress
  192.         fma.AddTimer 60, Self & ".SetOrderRepeat"
  193.     End Sub
  194.     Sub RepeatRelease
  195.         fma.DeleteTimer Self & ".SetOrderRepeat"
  196.         OrderQuit
  197.     End Sub
  198.         
  199.     Sub OrderQuit()
  200.         KeyManager.DeregisterAll Me
  201.         MenuStack.Top.Quit 'Remove emtpy menu
  202.     End Sub
  203.     ' Order End
  204.     
  205.     ' Volume Start (API)
  206.     Sub VolUp
  207.         ActiveXManager("WinampCOMLib.WinampCOMObj").Volumeup        'Send Vol+
  208.     End Sub
  209.     Sub VolDn
  210.         ActiveXManager("WinampCOMLib.WinampCOMObj").VolumeDown      'Send Vol-
  211.     End Sub
  212.     
  213.     Sub VolUpPress
  214.         fma.AddTimer 60, Self & ".VolUp"
  215.     End Sub
  216.     Sub VolUpRelease
  217.         fma.DeleteTimer Self & ".VolUp"
  218.     End Sub
  219.     
  220.     Sub VolDnPress
  221.         fma.AddTimer 60, Self & ".VolDn"
  222.     End Sub
  223.     Sub VolDnRelease
  224.         fma.DeleteTimer Self & ".VolDn"
  225.     End Sub
  226.     
  227.     Sub Volume()
  228.         EmptyMenu.ShowMenu
  229.         am.Back = Self & ".VolumeQuit" 'Mangage the menu quit by ourselves
  230.         'Volume Up
  231.         KeyManager.RegisterKey KEY_VOLUP,    Self & ".VolUpPress",   STATE_PRESS,   Me
  232.         KeyManager.RegisterKey KEY_JOYUP,    Self & ".VolUpPress",   STATE_PRESS,   Me
  233.         KeyManager.RegisterKey KEY_JOYRIGHT, Self & ".VolUpPress",   STATE_PRESS,   Me
  234.         KeyManager.RegisterKey KEY_VOLUP,    Self & ".VolUpRelease", STATE_RELEASE, Me
  235.         KeyManager.RegisterKey KEY_JOYUP,    Self & ".VolUpRelease", STATE_RELEASE, Me
  236.         KeyManager.RegisterKey KEY_JOYRIGHT, Self & ".VolUpRelease", STATE_RELEASE, Me
  237.         'Volume Down
  238.         KeyManager.RegisterKey KEY_VOLDOWN,  Self & ".VolDnPress",   STATE_PRESS,   Me
  239.         KeyManager.RegisterKey KEY_JOYDOWN,  Self & ".VolDnPress",   STATE_PRESS,   Me
  240.         KeyManager.RegisterKey KEY_JOYLEFT,  Self & ".VolDnPress",   STATE_PRESS,   Me
  241.         KeyManager.RegisterKey KEY_VOLDOWN,  Self & ".VolDnRelease", STATE_RELEASE, Me
  242.         KeyManager.RegisterKey KEY_JOYDOWN,  Self & ".VolDnRelease", STATE_RELEASE, Me
  243.         KeyManager.RegisterKey KEY_JOYLEFT,  Self & ".VolDnRelease", STATE_RELEASE, Me
  244.         am.DlgMsgBox "Joy-Up, -Right: Increase volume; Joy-Down, -Left: Decrease volume", 0
  245.     End Sub
  246.     
  247.     Sub VolumeQuit()
  248.         KeyManager.DeregisterAll Me
  249.         MenuStack.Top.Quit 'Remove emtpy menu
  250.     End Sub
  251.     ' Volume End
  252.  
  253. End Class